import * as React from "react";
import * as ReactDOM from "react-dom";

import "./NavBar.less";


export interface NavBarProps {
    title?: string,
    back?: string,
    searchClick?: Function
}

export interface State {

}

export default class NavBar extends React.Component<NavBarProps, State> {
    //默认属性
    static readonly defaultProps: NavBarProps = {};

    constructor(props: NavBarProps) {
        super(props);
        //默认状态
        this.state = {};
    }

    //组件挂载后回调
    componentDidMount() {
        document.title = "";

    }

    render() {
        return <>
            <div className="NavBar">
                <i className="iconfont icon-jiantou" onClick={() => {
                    if (this.props.back) {
                        location.hash = this.props.back;
                    } else {
                        history.back()
                    }
                }}/>
                <span>{this.props.title || '经销商后台'}</span>
                <span>
                {this.props.searchClick ?
                    <i className={'iconfont icon-sousuo'} onClick={() => {
                        this.props.searchClick()
                    }}/> : null}
            </span>
            </div>
            <div className="height4rem"> -</div>
        </>
    }
}
